package proxy.jdk2;

import proxy.Haha;

import java.lang.reflect.Proxy;
import java.util.ArrayList;
import java.util.List;

/**
 * @author ZhuQi
 * @ClassName Demo
 * @Date 2022/11/15 10:27
 * @Version 1.0
 * @Description TODO
 */
public class Demo {

    public static void main(String[] args) {
         // test01();

        ArrayList arrayList = new ArrayList();

        Handel handel = new Handel(arrayList);
        List list = (List)Proxy.newProxyInstance(arrayList.getClass().getClassLoader(), arrayList.getClass().getInterfaces(), handel);
        list.add("1111");

        for (Object o : list) {
            System.out.println(o);
        }
        System.out.println(list.hashCode());

        Class<?> proxyClass = Proxy.getProxyClass(null, List.class);
        System.out.println(proxyClass);

    }

    private static void test01() {
        HahaBook hahaBook = new HahaBook();
        Handel handel = new Handel(hahaBook);
        Haha haha = (Haha)Proxy.newProxyInstance(hahaBook.getClass().getClassLoader(),
                HahaBook.class.getInterfaces(),
                handel);
        String haha1 = haha.haha();
        System.out.println(haha1);
    }
}
